package cn.yyt.yytravel.like.controller;

import cn.yyt.yytravel.base.response.JsonResult;
import cn.yyt.yytravel.base.response.StatusCode;
import cn.yyt.yytravel.like.pojo.query.LikeQuery;
import cn.yyt.yytravel.like.pojo.query.SearchQuery;
import cn.yyt.yytravel.like.pojo.vo.LikeSceneVO;
import cn.yyt.yytravel.like.pojo.vo.LikeUserVO;
import cn.yyt.yytravel.like.service.LikeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/yyt/like/")
public class LikeController {
    @Autowired
    LikeService likeService;
    //进页面加载关注的所有用户
    @GetMapping("user/select/{id}")
    public JsonResult selectFollowUser(@PathVariable Long id){
        List<LikeUserVO> list = likeService.selectFollowUser(id);
        return JsonResult.ok(list);
    }
    //进页面加载关注的所有景区
    @GetMapping("scene/select/{id}")
    public JsonResult selectFollowScene(@PathVariable Long id){
        List<LikeSceneVO> list = likeService.selectFollowScene(id);
        return JsonResult.ok(list);
    }
    //删除用户关注
    @PostMapping("user/delete/")
    public JsonResult deleteFollowUser(LikeQuery likeQuery){
        likeService.deleteFollowUser(likeQuery);
        return JsonResult.ok();
    }
    //更新用户关注
    @PostMapping("user/update/")
    public JsonResult updateFollowUser(LikeQuery likeQuery){
        likeService.updateFollowUser(likeQuery);
        return JsonResult.ok();
    }
    //删除景区关注
    @PostMapping("scene/delete/")
    public JsonResult deleteFollowScene(LikeQuery likeQuery){
        likeService.deleteFollowScene(likeQuery);
        return JsonResult.ok();
    }
    //更新景区关注
    @PostMapping("scene/update/")
    public JsonResult updateFollowScene(LikeQuery likeQuery){
        likeService.updateFollowScene(likeQuery);
        return JsonResult.ok();
    }
    //按词条搜索用户
    @PostMapping("user/search")
    public JsonResult resetUserSearch(SearchQuery searchQuery){
        List<LikeUserVO> list = likeService.resetUserSearch(searchQuery);
        return JsonResult.ok(list);
    }
    //按词条搜索景区
    @PostMapping("scene/search")
    public JsonResult resetSceneSearch(SearchQuery searchQuery){
        List<LikeSceneVO> list = likeService.resetSceneSearch(searchQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("guide")
    public JsonResult getUserFollow(LikeQuery likeQuery){
        Boolean b = likeService.getUserFollow(likeQuery);
        return JsonResult.ok(b);
    }
    @PostMapping("scene/follow")
    public JsonResult getSceneFollow(LikeQuery likeQuery){
        Boolean b = likeService.getSceneFollow(likeQuery);
        return JsonResult.ok(b);
    }


}
